'''
Created on Apr 6, 2013

@author: kevinbauer
'''

import numpy as np

class Test(object):

    def __init__(self, w, test):
        self.weights = w
        self.testData = test
        
    def runTest(self):
        
        results = [] # 1 for attack, 0 if normal. The index of this array corresponds to the index of the test data.
        shape = np.shape(self.testData)
        rows = shape[0]
        columns = shape[1]
        
        i = 0
        while i < rows:
            j = 0
            temp = []
            
            # Get the products of the weights and values of each node.
            while j < columns:
                temp.append(self.weights[j] * self.testData[i,j])
                j += 1
            
            input = sum(temp) # Get the sum of all the products, the weights multiplied by the values per record.
            
            # Activation function.
            if  input > 0.5:
                results.append(1)
            else:
                results.append(0)
            
            i += 1
        
        return results